Changing module to Read-Only fires "Module Close" trigger

Here's another oddity with the way that DOORS handles the change of edit mode...

If you follow the standard DOORS wiki, for implementing a dynamic module-close trigger, to close a modeless Dialog Box when the module is closed:

http://www.ibm.com/developerworks/wikis/display/dxl/Triggers

The trigger function is defined as:

bool closeDialogOnModuleClose(Trigger t) {
   closeDB(example_DB);
   return(true);
}

 

However, for some reason, if you downgrade from Exclusive or Shareable to Read, the trigger fires and the Dialog Box is closed!


To prevent this, I have modified the trigger function to:

 

 

bool closeDialogOnModuleClose(Trigger t) {
   if (module(t) != null) return(true);
   closeDB(example_DB);
   return(true);
}



It works, but was wondering if anyone knows of any undesirable consequences of doing this.

 

 


SystemAdmin - Tue Jan 08 07:03:23 EST 2013

Re: Changing module to Read-Only fires "Module Close" trigger
llandale - Tue Jan 08 09:40:42 EST 2013

Yes I've seen that.

For a pre-close trigger (which you have in your example), I would have thought that the module(t) is indeed still open (since the trigger fires before the module closes) and thus your modification would never close the dialog, even when you want it to. If your code works (when you actually "close") then I wonder what is wrong with my thinking here.

-Louie

Re: Changing module to Read-Only fires "Module Close" trigger
SystemAdmin - Tue Jan 08 10:15:33 EST 2013

llandale - Tue Jan 08 09:40:42 EST 2013
Yes I've seen that.

For a pre-close trigger (which you have in your example), I would have thought that the module(t) is indeed still open (since the trigger fires before the module closes) and thus your modification would never close the dialog, even when you want it to. If your code works (when you actually "close") then I wonder what is wrong with my thinking here.

-Louie

I thought it was being destroyed, but was actually hidden by the DOORS Explorer being brought to the fore :)

I changed the trigger callback function to a void function, thus changing it into a post-close trigger, and it works as expected.

Thanks for the thoughts Louie

Re: Changing module to Read-Only fires "Module Close" trigger
SystemAdmin - Tue Jan 08 11:28:56 EST 2013

SystemAdmin - Tue Jan 08 10:15:33 EST 2013
I thought it was being destroyed, but was actually hidden by the DOORS Explorer being brought to the fore :)

I changed the trigger callback function to a void function, thus changing it into a post-close trigger, and it works as expected.

Thanks for the thoughts Louie

So, the final way I catered for this scenario is to:

  • close the DB if the module is null
  • if it isn't null, if the module is visible, don't close the DB
  • if it isn't null and the module is not visible, close the DB

 

void closeDialogOnModuleClose(Trigger t)
{
   Module modTrg = module(t)
   if (null(modTrg))
   {
       closeDB(example_DB)
       return
   }
   if (isVisible(modTrg)) return
   closeDB(example_DB)
   return
}

 

Re: Changing module to Read-Only fires "Module Close" trigger
llandale - Tue Jan 08 13:51:06 EST 2013

SystemAdmin - Tue Jan 08 11:28:56 EST 2013

So, the final way I catered for this scenario is to:

  • close the DB if the module is null
  • if it isn't null, if the module is visible, don't close the DB
  • if it isn't null and the module is not visible, close the DB

 

void closeDialogOnModuleClose(Trigger t)
{
   Module modTrg = module(t)
   if (null(modTrg))
   {
       closeDB(example_DB)
       return
   }
   if (isVisible(modTrg)) return
   closeDB(example_DB)
   return
}

 

The natural close callback for the dialog should either:
  1. delete the trigger
  2. set the example_DB variable to null; and your trigger should check for that.

Otherwise if you close the dialog and then close the module, the trigger will fire and attempt to access an invalid DB handle.

-Louie